<template>
  <div class="app-container">
    <el-table v-loading="loading" :data="routeproductbomList">
      <el-table-column label="序号" align="center" width="50px" >
        <template slot-scope="scope">
          <span>{{scope.$index + 1}}</span>
        </template>
      </el-table-column>
      <el-table-column label="补料编码" align="center" prop="supplyCode">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="handleCheck(scope.row)"
          >
            {{  scope.row.supplyCode   }}
          </el-button>
        </template>
      </el-table-column>
      <el-table-column label="工单编号" align="center" prop="workorderCode" />
      <!-- <el-table-column label="审核人" align="center" prop="checkUser" /> -->
      <el-table-column label="补料状态" align="center" prop="supplyStatusName" />
      <el-table-column label="补料时间" align="center" prop="supplyTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.supplyTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="领料人" align="center" prop="createBy" />
      <!-- <el-table-column label="审核时间" align="center" prop="checkTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.checkTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column> -->
      <el-table-column label="备注" align="center" prop="remark" />
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <SupplyDetails ref="supplyDetails"  :supplyId="parentId"></SupplyDetails>
  </div>
</template>
    
  <script>
import { listSupply } from "@/api/mes/pro/workorder";
import SupplyDetails from '../../materialSupply/detail.vue';
export default {
  name: "material",
  components: { SupplyDetails },
  props: {
    workorderCode: null,
    productId: null,
    processId: null,
    optType: null,
    buttonType: null,
    workorderId: null
  },
  dicts: ["mes_workorder_status"],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 产品制程物料BOM表格数据
      routeproductbomList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      parentId:"",
      // 查询参数
      queryParams: {
        workorderCode: this.workorderCode,
        pageNum: 1,
        pageSize: 10,
        
      }
    };
  },
  created() {
    this.getList();
  },
  watch: {
    workorderCode: function(val) {
      this.workorderCode = val;
      this.queryParams.workorderCode = val;
      if(val){
        this.getList();
      }
    }
    // workorderId: function(val) {
    //   this.workorderId = val;
    //   this.queryParams.workorderId = val;
    //   this.getList();
    // },
  },
  methods: {
    getList() {
      this.loading = true;
      listSupply(this.queryParams).then(response => {
        console.info("response.rows", response.rows);
        this.routeproductbomList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.recordId);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    handleCheck(row) {
      this.parentId = row.id 
      this.$refs.supplyDetails.showFlag = true;
    }
  }
};
</script>
    